<template>
  <div v-loading="isLoading">
    <el-card v-for="item in list" :key="item.id" shadow="hover" class="course-item" @click.native="handleDeatail(item.id)">
      <el-row type="flex" align="middle">
        <div style="width: 260px; border-right: 1px solid; margin-right: 20px;">
          {{ parseTime(item.classTime[0].startTime | '', '{y}-{m}-{d} {h}:{i}') +
            '-' + parseTime(item.classTime[0].endTime | '', '{h}:{i}') }}
        </div>
        <div style="width: 90%; font-size: 20px;">
          {{ item.name }}
        </div>
        <div style="width: 200px;">
          上课地点：{{ item.classTime[0].place }}
        </div>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { getStudentCourse } from '@/api/course'
import { parseTime } from '@/utils'

export default {
  name: 'MineCourse',
  data() {
    return {
      list: [],
      isLoading: true
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.isLoading = true
      getStudentCourse().then(res => {
        this.list = res.data
        this.isLoading = false
      })
    },
    parseTime,
    // 跳转课程详情页面
    handleDeatail(courseId) {
      console.log(courseId)
      this.$router.push('/detail?csId=' + courseId)
    }
  }
}
</script>

<style scoped>
.course-item {
  margin: 10px;
  background-color: #FFF;
  cursor: pointer;
}
</style>
